const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let xStr, yStr;
rl.on("line", (line)=>{
    if(xStr === undefined) {
        [xStr, yStr] = line.trim().split(" ")
        console.log(getResult(xStr, yStr))
        // clear
        xStr = yStr = undefined
    }

})

function getResult(xStr, yStr) {
    let dp = new Array(yStr.length + 1).fill(null).map(() => new Array(xStr.length + 1).fill(Infinity))
    //init 横向
    for (let i = 0; i <= xStr.length ; i++) {
        dp[0][i] = i
    }
    // init 纵向
    for (let i = 0; i <= yStr.length ; i++) {
        dp[i][0] = i
    }

    for (let i = 1; i <= yStr.length ; i++) {
        for (let j = 1; j <= xStr.length ; j++) {
            let yChar = yStr[i - 1]
            let xChar = xStr[j - 1]
            if(yChar === xChar) {
                dp[i][j] = Math.min(dp[i - 1][j]  + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + 1)
            } else {
                dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1)
            }
        }
    }
    return dp[yStr.length][xStr.length]

}